package com.linkage.bss.crm.packagemgr.smo.impl;

import java.util.List;
import java.util.Map;

import com.linkage.bss.commons.dao.Page;
import com.linkage.bss.commons.exception.SmoException;
import com.linkage.bss.crm.packagemgr.bmo.IPackageManagerBMO;
import com.linkage.bss.crm.packagemgr.dto.PackInfoDto;
import com.linkage.bss.crm.packagemgr.model.Package;
import com.linkage.bss.crm.packagemgr.smo.IPackageManagerSMO;
import com.linkage.bss.crm.packagemgr.util.Constant;

/**
 *
 * 包管理 SMO
 *
 * @author  olns
 * @version  [版本号, 2013-4-28]
 * @see  [相关类/方法]
 * @since  [产品/模块版本]
 */
public class PackageManagerSMOImpl implements IPackageManagerSMO {

	private IPackageManagerBMO packageManagerBMO;

	public IPackageManagerBMO getPackageManagerBMO() {
		return packageManagerBMO;
	}

	public void setPackageManagerBMO(IPackageManagerBMO packageManagerBMO) {
		this.packageManagerBMO = packageManagerBMO;
	}

	public int getPackageByCondCount(Map map) {
		return packageManagerBMO.getPackageByCondCount(map);
	}

	public List<Package> getPackageByCond(Map map, Page page) {

		return packageManagerBMO.getPackageByCond(map, page);
	}

	public Package getPackageByID(Long packageId) {
		return getPackageManagerBMO().getPackageById(packageId);
	}

	public void savePackage(Package pack) {
		packageManagerBMO.savePackage(pack);

	}

	/**
	 * 包修改
	 * @param pack
	 * @return [参数说明]
	 *
	 * @return boolean [返回类型说明]
	 * @exception throws [违例类型] [违例说明]
	 * @see [类、类#方法、类#成员]
	 */
	public boolean updatePackage(Package pack, Map operateMap) {
		return packageManagerBMO.updatePackage(pack, operateMap);
	}

	public PackInfoDto queryPackInfoByPackId(Long packId) {

		try {
			return packageManagerBMO.queryPackInfoByPackId(packId);
		} catch (Exception e) {
			throw new SmoException(Constant.CHECK_FALSE, e.getMessage());
		}

	}

	public boolean delPackage(List<Package> packIdList) {
		try {

			for (Package pack : packIdList) {
				packageManagerBMO.delPackageAllById(pack.getPackageId());
			}
			return true;

		} catch (Exception e) {
			throw new SmoException(Constant.DEL_FALSE, e.getMessage());
		}
	}

}
